<?php
/**
 * Created by PhpStorm.
 * User: robot
 * Date: 2018-04-21
 * Time: 16:25
 */

namespace app\index\controller;


use app\base\BaseController;
use app\base\model\Article;
use app\base\model\Sort;
use think\Request;

class Articlelist extends BaseController
{
    public function index()
    {
        $request = Request::instance();
        $page = $request->has('page') ? $request->param('page') : 1;
        $limit = 5;
        $offset = $limit * $page-$limit;
        $article = new Article();
        $sort = $request->param('sort');
        $this->assign('page', $page);
        $this->assign('sort', $sort);
        $this->assign('sort_name',Sort::get($sort)->sortname);
        $this->assign('article_list',$article->where('sort',$sort)->limit($offset,$limit)->select());
        $this->assign('article_count',$article->where('sort',$sort)->count('articid'));
        return $this->fetch();
    }

}